package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SaleAnalyse02;
import com.ruoyi.system.service.ISaleAnalyse02Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 销售报表Controller
 * 
 * @author ruoyi
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/system/xiaoshou")
public class SaleAnalyse02Controller extends BaseController
{
    @Autowired
    private ISaleAnalyse02Service saleAnalyse02Service;

    /**
     * 查询销售报表列表
     */
    @PreAuthorize("@ss.hasPermi('system:xiaoshou:list')")
    @GetMapping("/list")
    public TableDataInfo list(SaleAnalyse02 saleAnalyse02)
    {
        startPage();
        List<SaleAnalyse02> list = saleAnalyse02Service.selectSaleAnalyse02List(saleAnalyse02);
        return getDataTable(list);
    }

    /**
     * 导出销售报表列表
     */
    @PreAuthorize("@ss.hasPermi('system:xiaoshou:export')")
    @Log(title = "销售报表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SaleAnalyse02 saleAnalyse02)
    {
        List<SaleAnalyse02> list = saleAnalyse02Service.selectSaleAnalyse02List(saleAnalyse02);
        ExcelUtil<SaleAnalyse02> util = new ExcelUtil<SaleAnalyse02>(SaleAnalyse02.class);
        util.exportExcel(response, list, "销售报表数据");
    }

    /**
     * 获取销售报表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:xiaoshou:query')")
    @GetMapping(value = "/{saleid}")
    public AjaxResult getInfo(@PathVariable("saleid") Long saleid)
    {
        return success(saleAnalyse02Service.selectSaleAnalyse02BySaleid(saleid));
    }

    /**
     * 新增销售报表
     */
    @PreAuthorize("@ss.hasPermi('system:xiaoshou:add')")
    @Log(title = "销售报表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SaleAnalyse02 saleAnalyse02)
    {
        return toAjax(saleAnalyse02Service.insertSaleAnalyse02(saleAnalyse02));
    }

    /**
     * 修改销售报表
     */
    @PreAuthorize("@ss.hasPermi('system:xiaoshou:edit')")
    @Log(title = "销售报表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SaleAnalyse02 saleAnalyse02)
    {
        return toAjax(saleAnalyse02Service.updateSaleAnalyse02(saleAnalyse02));
    }

    /**
     * 删除销售报表
     */
    @PreAuthorize("@ss.hasPermi('system:xiaoshou:remove')")
    @Log(title = "销售报表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{saleids}")
    public AjaxResult remove(@PathVariable Long[] saleids)
    {
        return toAjax(saleAnalyse02Service.deleteSaleAnalyse02BySaleids(saleids));
    }
}
